package com.zxl.live.screen.ads.listener;

import com.google.android.gms.ads.AdListener;
import com.zxl.live.tools.analytics.AnalyticsHelper;
import com.zxl.live.tools.analytics.Params;

/**
 * Created by Administrator on 2018/2/6.
 */

public class AdBannerAdapter extends AdListener {

    private String type;

    private AdListener mProxy;

    public AdBannerAdapter(String type, AdListener mProxy) {
        this.type = type;
        this.mProxy = mProxy;
    }

    public void setProxy(AdListener mProxy) {
        this.mProxy = mProxy;
    }

    @Override
    public void onAdClosed() {
        AnalyticsHelper.logEvent(type, Params.CLOSE);
        if (mProxy != null) {
            mProxy.onAdClosed();
        }
    }

    @Override
    public void onAdFailedToLoad(int i) {
        AnalyticsHelper.logEvent(new AnalyticsHelper.LogEvent(type).addParam(Params.FAILED, i));
        if (mProxy != null) {
            mProxy.onAdFailedToLoad(i);
        }
    }

    @Override
    public void onAdLeftApplication() {
        AnalyticsHelper.logEvent(type, Params.AD_LEFT);
        if (mProxy != null) {
            mProxy.onAdLeftApplication();
        }
    }

    @Override
    public void onAdOpened() {
        AnalyticsHelper.logEvent(type, Params.OPENED);
        if (mProxy != null) {
            mProxy.onAdOpened();
        }
    }

    @Override
    public void onAdLoaded() {
        AnalyticsHelper.logEvent(type, Params.LOADED);
        if (mProxy != null) {
            mProxy.onAdLoaded();
        }
    }

    @Override
    public void onAdClicked() {
        AnalyticsHelper.logEvent(type, Params.CLICKED);
        if (mProxy != null) {
            mProxy.onAdClicked();
        }
    }

    @Override
    public void onAdImpression() {
        AnalyticsHelper.logEvent(type, Params.IMPRESSION);
        if (mProxy != null) {
            mProxy.onAdImpression();
        }
    }
}
